package com.tarry.controller;

import com.tarry.service.ICityService;
import com.tarry.web.domian.vo.ResultEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/city")
public class CityController {

    private final ICityService cityService;

    @Autowired
    public CityController(ICityService cityService) {
        this.cityService = cityService;
    }

    @GetMapping("/{id}")
    public ResultEntity getCity(@PathVariable("id") String cityCode) {
        return ResultEntity.success(cityService.getByCode(cityCode));
    }
}
